package com.liwenfeng;

import java.io.IOException;

/*
* public static Runtime getRuntime()  猎取当前系统的运行环境对象；
*        void   exit(int status)      停止虚拟机
*        int    availableProcessors() 获取CPU的线程数
*        long   maxMemory()           JVM能从系统中获得总内存大小
*        long   totalMemory()         JVM已经从系统中获取的总内存大小
*        long   freeMemory()          JVM剩余内存大小
*        process exec(String command) 运行cmd命令
* */
public class RuntimeCommand {
    public static void main(String[] args) throws IOException {
        Runtime runtime = Runtime.getRuntime();
//        runtime.exit(0);
        System.out.println(runtime.availableProcessors());//8
        System.out.println(runtime.maxMemory() / 1024 / 1024);//4068
        System.out.println(runtime.totalMemory() / 1024 / 1024);//256
        System.out.println(runtime.freeMemory() / 1024 / 1024);//249
//        Process ipconfig = runtime.exec(new String[]{"notepad"});
//        Process ipconfig = runtime.exec(new String[]{"shutdown","-s" ,"-t","3600"});//设定60分钟后自动关机
        Process ipconfig = runtime.exec(new String[]{"shutdown","-a"});//取消自动关机

    }
}
